using System.Collections;
using System.Data;

namespace PopMail
{
    /// <summary>
    /// Container class that holds mail attachment details
    /// </summary>
    public class POP3MailAttachment
    {
        private string _contentType;
        private string _charset;
        private string _contentTransferEncoding;
        private string _attachmentName;
        private string _attachmentStream;
        private string _messageSignature;
        private int _startOfBoundary;
        private int _endOfBoundary;
        private bool _partiallyProcessed;

        /// <summary>
        /// Public constructor of POP3MailAttachment
        /// </summary>
        public POP3MailAttachment()
        {
            _contentType = string.Empty;
            _charset = string.Empty;
            _contentTransferEncoding = string.Empty;
            _attachmentName = string.Empty;
            _attachmentStream = string.Empty;
            _partiallyProcessed = false;
            _messageSignature = string.Empty;
        }

        /// <summary>
        /// Unique signature of the message
        /// </summary>
        public string MessageSignature
        {
            get { return _messageSignature; }
            set { this._messageSignature = value; }
        }

        /// <summary>
        /// Content Type
        /// </summary>
        public string ContentType
        {
            get { return _contentType; }
            set { this._contentType = value; }
        }

        /// <summary>
        /// Charset
        /// </summary>
        public string Charset
        {
            get { return _charset; }
            set { this._charset = value; }
        }

        /// <summary>
        /// Encoding
        /// </summary>
        public string Encoding
        {
            get { return _contentTransferEncoding; }
            set { this._contentTransferEncoding = value; }
        }

        /// <summary>
        /// Name of the attachment
        /// </summary>
        public string Name
        {
            get { return _attachmentName; }
            set { this._attachmentName = value; }
        }

        /// <summary>
        /// Attachment Stream
        /// </summary>
        public string Stream
        {
            get { return _attachmentStream; }
            set { this._attachmentStream = value; }
        }

        /// <summary>
        /// Start boundary of the attachment
        /// </summary>
        public int StartOfBoundary
        {
            get { return _startOfBoundary; }
            set { this._startOfBoundary = value; }
        }

        /// <summary>
        /// End boundary of the attachment
        /// </summary>
        public int EndOfBoundary
        {
            get { return _endOfBoundary; }
            set { this._endOfBoundary = value; }
        }

        /// <summary>
        /// Method to check if the header retrieval is complete
        /// </summary>
        /// <returns></returns>
        public bool IsHeaderRetrievalComplete()
        {
            if(   ! _contentType.Equals(string.Empty) 
               && ( ! _charset.Equals(string.Empty) || ! _attachmentName.Equals(string.Empty))
               && ! _contentTransferEncoding.Equals(string.Empty))
               //&& ! _attachmentName.Equals(string.Empty)
               //&& ! _attachmentStream.Equals(string.Empty)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        /// <summary>
        /// Method to check if the attachment is partially processed
        /// </summary>
        public bool IsPartiallyProcessed
        {
            get { return _partiallyProcessed; }
            set { this._partiallyProcessed = value; }
        }

        ///// <summary>
        ///// Method to prepare the database param list
        ///// </summary>
        ///// <param name="emailId"></param>
        ///// <returns></returns>
        //public ArrayList DbParamList(long emailId)
        //{
        //    ArrayList paramList = new ArrayList();

        //    DBUtilities dbUtilities = new DBUtilities();

        //    //paramList.Add(dbUtilities.CreateSqlParamater("@emailID",SqlDbType.Int,ParameterDirection.Input,emailId));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@contentType", SqlDbType.NVarChar, 50, ParameterDirection.Input, this.ContentType));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@charset", SqlDbType.NVarChar, 50, ParameterDirection.Input, this.Charset));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@contentTransferEncoding", SqlDbType.NVarChar,50, ParameterDirection.Input, this.Encoding));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@attachmentName", SqlDbType.NVarChar, 255, ParameterDirection.Input, this.Name));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@startOfBoundary", SqlDbType.Int, ParameterDirection.Input, this.StartOfBoundary));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@endOfBoundary", SqlDbType.Int, ParameterDirection.Input, this.EndOfBoundary));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@attachmentStream", SqlDbType.NText, ParameterDirection.Input, this.Stream));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@messageSignature", SqlDbType.NVarChar,32, ParameterDirection.Input, this._messageSignature));
        //    paramList.Add(dbUtilities.CreateSqlParamater("@insertStatus", SqlDbType.Bit, ParameterDirection.Output));

        //    dbUtilities = null; //Dispose off the utilities object before returning the list

        //    return paramList;

        //}
    }
}
